<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateLogTable extends Migration
{
    /**
     * Run the migrations.
     * 日志
     * @return void
     */
    public function up()
    {
        Schema::create('log', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->charset = 'utf8';
            $table->collation = 'utf8_general_ci';

            $table->increments('id');
            $table->integer('user_id')->comment('操作用户');
            $table->string('client_ip')->comment('客户端ip');
            $table->string('action',255)->comment('操作节点，‘类名/方法名‘');
            $table->string('url',255)->comment('访问地址');
            $table->text('params')->comment('访问参数')->nullable();
            $table->string('remark',50)->comment('说明')->nullable();
            $table->index('user_id','user_id_index');
            $table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('log');
    }
}
